﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace IFWiki
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("Game",
            "Play/{name}",
            new { controller = "Game", action = "Index", name = "" });

            routes.MapRoute("HistoryViewSource",
            "History/ViewSource/{innerType}/{name}",
            new { controller = "History", action = "ViewSource", innerType = "Article", name = "IF Wiki" });



            routes.MapRoute("History",
            "History/{innerType}/{name}",
            new { controller = "History", action = "List", innerType = "Article", name = "IF Wiki" });

        //http://localhost:3784/History/List?innerType=IFWiki.Models.Article


            routes.MapRoute("GamePlace",
                "Go/{placeName}/{gameName}",
                new { controller = "GamePlace", action = "Go", placeName = "", gameName = "" });


            routes.MapRoute(
                "Read",                                              // Route name
                "{name}",                           // URL with parameters
                new { controller = "Article", action = "Index", name = "IF Wiki" }  // Parameter defaults
            );
            
            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{name}",                           // URL with parameters
                new { controller = "Article", action = "Index", name = "IF Wiki" }  // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
            IFWiki.Utils.Persister.BasePath = Server.MapPath("~/App_Data"); 
        }
    }
}